package com.bawei.lizhiyu1228.greendao;

import android.database.sqlite.SQLiteDatabase;

import com.bawei.App;
import com.bawei.lic_core.db.DaoMaster;
import com.bawei.lic_core.db.DaoSession;

/**
 * @author : zhiyu
 * @date : 2021/12/28
 * @content :
 */
public class DaoManager {

    private static DaoManager daoManager;

    private final DaoSession daoSession;

    public static DaoManager getInstance(){
        if (daoManager==null){
            synchronized (DaoManager.class){
                if (daoManager==null){
                    daoManager=new DaoManager();
                }
            }
        }

        return daoManager;
    }


    public DaoManager() {
        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(App.context, "us.db");

        SQLiteDatabase db = devOpenHelper.getWritableDatabase();

        daoSession = new DaoMaster(db).newSession();
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}
